﻿<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mp3Player.aspx.vb" Inherits="mp3Player" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="MediaPlayer/swfobject.js"></script>
    <script type="text/javascript" src="MediaPlayer/ep_player.js"></script>    
</head>
<body bgcolor="#0b5eba">
    <form id="form1" runat="server">

    <asp:ScriptManager ID="scriptManager" runat="server" EnablePageMethods="true" />

    <p id='preview'>The player will show in this paragraph</p>

    <script language="javascript" type="text/javascript">
    		var so = new SWFObject("MediaPlayer/ep_player.swf", "ep_player", "100", "100", "9", "#FFFFFF");
	    	so.addVariable("skin", "MediaPlayer/skins/micro_player/skin.xml");
		    so.addVariable("autoplay", "false");
		    so.addVariable("shuffle", "false");
		    so.addVariable("repeat", "false");
		    so.addVariable("buffertime", "1");
		    so.addVariable("notifyonevent", "true");
		    so.addParam("allowscriptaccess", "always");
		    so.write("preview");

		    /*--------------------------------------------------------------*/

		    function EP_eventHandler(evt) {
		        _event = evt;
		        switch (evt) {
		            case 'MP3_LOADING':
		                break;
		            case 'MP3_BUFFERING':
		                break;
		            case 'MP3_PLAYING':
		                break;
		            case 'MP3_PREV':
		                break;
		            case 'MP3_NEXT':
		                break;
		            case 'MP3_SELECT':
		                break;
		            case 'MP3_PAUSED':
		                break;
		            case 'MP3_COMPLETE':
		                PageMethods.Next(play_next_song);
		            case 'MP3_STOPPED':
		                break;
		            default:
		                break;
		        }
		    }

		    function play_song(songId, isFromPlaylist) {
		        var songFileName = "<location>Handlers/GetSong.ashx?" + songId + "</location>"
		        EP_loadMP3('ep_player', songFileName);
		        EP_play('ep_player');
		        PageMethods.ChangePlayerStatus('Playing',songId,true,isFromPlaylist,update_display);
		    }

		    function play_next_song(songId) {
		        if (songId != 0)
		        {
    		        var songFileName = "<location>Handlers/GetSong.ashx?" + songId + "</location>"
	    	        EP_loadMP3('ep_player', songFileName);
	    	        EP_play('ep_player');
	    	        PageMethods.ChangePlayerStatus('Playing',songId,true,true,update_display);
	    	    }
	    	    else {
	    	        PageMethods.ChangePlayerStatus('Stopped',0,true,false,update_display);
		        }
		    }

		    function update_display(songId) {
		        parent.visibleFrame.player_song_changed(songId);
		    }
		    
		    function pause() {
		        EP_pause('ep_player');
		        PageMethods.ChangePlayerStatus('Paused',0,false,false);		        
		    }

		    function play() {
		        EP_play('ep_player');
		        PageMethods.ChangePlayerStatus('Playing',0,false,false);
		    }
		    
    </script>

    </form>
</body>
</html>
